package com.ihealthway.all.groupbuy.modules.admin;

import com.ihealthway.all.slog.annotation.SLog;
import com.ihealthway.all.commons.Constants;
import com.ihealthway.all.groupbuy.services.MPSettingService;
import com.ihealthway.all.utils.Ajax;
import com.ihealthway.all.utils.AjaxReturn;
import com.ihealthway.all.groupbuy.vo.MPSetting;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.*;
import org.nutz.mvc.upload.UploadAdaptor;

/**
 * Background WeChat setting module class
 *
 * @author 凡梦星尘(elkan1788@gmail.com)
 */
@At("/admin/wechat")
@IocBean
public class WeChatSettingModule {

    private static final Log logger = Logs.get();

    @Inject
    private MPSettingService mpSetService;

    @At
    @Ok("beetl:admin/mpsetting.jsp")
    public void mpSetting() {
        logger.info("Enter MP Setting page.");
    }

    @At
    public MPSetting getMPInfo() {
        return mpSetService.get();
    }

    @At
    @SLog(module = Constants.MODULE_WECHAT, type = Constants.OPERATE_TYPE_UPDATE, content = "更新公众服务号配置信息")
    public AjaxReturn updateMPInfo(@Param("..")MPSetting mpSetting) {

        return mpSetService.update(mpSetting);
    }

    @At
    @Ok("beetl:admin/mchsetting.jsp")
    public void mchSetting() {
        logger.info("Enter MCH Setting page.");
    }


    @At
    @AdaptBy(type = UploadAdaptor.class, args = { "ioc:uploadImg" })
    @SLog(module = Constants.MODULE_WECHAT, type = Constants.OPERATE_TYPE_UPDATE, content = "更新公众服务号支付信息")
    public AjaxReturn updateMCHInfo(@Param("..")NutMap nutMap) {

        logger.info(nutMap);
//        return mpSetService.update(mpSetting);
        return Ajax.ok();
    }

    @At
    @Ok("beetl:admin/welcome.jsp")
    public void followReply() {
        logger.info("Enter MP follow reply page.");
    }


    @At
    @SLog(module = Constants.MODULE_WECHAT, type = Constants.OPERATE_TYPE_UPDATE, content = "更新关注回复语信息")
    public AjaxReturn updateWelcomeSent(@Param("..")MPSetting mpSetting) {

        return mpSetService.update(mpSetting);
    }


}
